<?php
class PapiWS_Model_ShapeVO extends PapiWS_Model_GraphicalObjectVO
{
	const SHAPE = 'shape';
	
	// drupal related info
	public $id;
	public $name;
	public $svgUrl;
	public $swfUrl;
	public $pngUrl;
	public $images;
	public $tint;
	public $userImage;
		
	
	public function __construct( $data  = null)
	{
		$this->type = PapiWS_Model_ShapeVO::SHAPE;

		if ( $data == null )
			return;

		$drupalUrl = Zend_Registry::get('config')->drupal->url;
		$this->id = $data['nid'];

		if( isset($data['field_swf'][0]['filepath']) ) {
			$this->swfUrl = $drupalUrl . $data['field_swf'][0]['filepath'];
		}

		if( isset($data['field_svg'][0]['filepath']) ) {
			$this->svgUrl = $drupalUrl . $data['field_svg'][0]['filepath'];
		}

		if( isset($data['field_png'][0]['filepath']) ) {
			$this->pngUrl = $drupalUrl . $data['field_png'][0]['filepath'];
			
			list($this->width, $this->height ) = @getimagesize( $this->pngUrl );
		}
		
		if( isset($data['title'])) {
			$this->name = $data['title'];
		}
		
		if( isset($data['images']) ) {
			$this->images = $data['images'];
		}
	}
}
